package date0701;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class JdbcTest03 {

	public static void main(String[] args) throws SQLException {
		
		Connection connection = JdbcUtil.connect();
		Statement statement = JdbcUtil.create(connection);
		
		String SQL = JdbcUtil.input();
		
		SQL = SQL.trim().toUpperCase();
		
		if( SQL.startsWith( "INSERT" ) ||SQL.startsWith( "UPDATE" ) || SQL.startsWith( "DELETE" )   ) {
			// 4、"执行" DML 语句 : INSERT 、UPDATE 、DELETE
			int count = statement.executeUpdate( SQL ); // SQLException
			// 5、输出执行结果
			System.out.println( "受当前SQL影响的记录数目: " + count );
		}else {
			System.out.println( "不是DML语句: " + SQL );
		}
		
		JdbcUtil.close(statement);
		JdbcUtil.close(connection);

	}

}
